import { IPagination } from '@/views/types';
import { PaginationProps } from 'antd';
import { useState } from 'react';

const usePagination = function (
    filterParams: IPagination,
    getGoods: (params?: IPagination | undefined) => Promise<void>,
) {
    const [current, setCurrent] = useState(1);
    const onChange: PaginationProps['onChange'] = (page) => {
        setCurrent(page);
        filterParams.pageNumber = page;
        getGoods({
            ...filterParams,
        });
    };
    return {
        setCurrent,
        onChange,
        current,
    };
};
export default usePagination;
